//认证

import Http from "../utils/HttpUtil";
import URL from "./URL";
export default{
    //  无人机认证 
    async  AddAuthenticationAerocraft(userId,title,brand,type,model,SN,insuranceStatus,
        insuranceCompany,insuranceNumber,insuranceDate,aerocraftImg,insuranceImg){
        let url=URL.GetURL(URL.AddAuthenticationAerocraft);
        let imgs=[
            ['aerocraftImg',aerocraftImg],
            ['insuranceImg',insuranceImg]
        ];
        let data=[
            ["userId",userId],
            ["title",title],
            ["brand",brand],
            ["type",type],
            ["model",model],
            ["SN",SN],
            ["insuranceStatus",insuranceStatus?"0":"1"],
            ["insuranceCompany",insuranceCompany],
            ["insuranceNumber",insuranceNumber],
            ["insuranceDate",insuranceDate],
        ];
        // console.log(imgs);
        // console.log(data);

        return await(Http.PostWithFile(url,data,imgs))
        .then(response=>{
            return(response)
        },reject=>{
            return Promise.reject(reject);
        });
    },

    //  飞行执照认证 
    async  AddCertificate(userId,type,number,date,imgJust,imgBack){
        let url=URL.GetURL(URL.AddCertificate);
        // let para={userId,type,number,date};
        let imgs=[
                    ['imgJust',imgJust],
                    ['imgBack',imgBack]
                ];
        let data=[
            ["userId",userId],
            ["type",type],
            ["number",number],
            ["date",date]
        ];
        // console.log(imgs)
        return await(Http.PostWithFile(url,data,imgs))
        .then(response=>{
            return(response)
        },reject=>{
            return Promise.reject(reject);
        });
    },

    //  查询无人机认证
    async  SelectAerocraftList(userId){
        let url=URL.GetURL(URL.SelectAerocraftList);
        let para={userId};
        return await(Http.Post(url,para))
        .then(response=>{
            return(response)
        },reject=>{
            return Promise.reject(reject);
        });
    },


    //  查询飞行执照认证
    async  SelectCertificateList(userId){
        let url=URL.GetURL(URL.SelectCertificateList);
        let para ={userId};
        return await(Http.Post(url,para))
        // return await(Http.Get(url+"?userId="+userId))
        .then(response=>{
            return(response)
        },reject=>{
            return Promise.reject(reject);
        });
    },

    //  删除无人机认证 
    async  DeleteAerocraft(aerocraftId){
        let url=URL.GetURL(URL.DeleteAerocraft);
        let para={aerocraftId};
        return await(Http.Post(url,para))
        .then(response=>{
            return(response)
        },reject=>{
            return Promise.reject(reject);
        });
    },

    //  删除飞行执照认证 
    async  DeleteCertificate(certificateId){
        let url=URL.GetURL(URL.DeleteCertificate);
        let para={certificateId};
        return await(Http.Post(url,para))
        .then(response=>{
            return(response)
        },reject=>{
            return Promise.reject(reject);
        });
    }
}
